#ifndef SEQIOT_MODBUS_ACQUIRE_H
#define SEQIOT_MODBUS_ACQUIRE_H

#include "config.h"
#include "value.h"

void value_transform(device_t *device, thing_model_t *model, value_t *value);

void modbus_decode_registers(device_t *device, thing_model_t *thing_model, const uint16_t *payload, value_t *value);

int modbus_collect_cols(channel_t *channel, device_t *device,
                        segment_e segment, vector_t *tag_list, int offset, int nb);

int modbus_collect_registers(channel_t *channel, device_t *device,
                             segment_e segment, vector_t *tag_list, int offset, int nb);

int modbus_collect(channel_t *channel, device_t *device,
                   segment_e segment, vector_t *tag_list, int offset, int nb);

int modbus_init(channel_t *channel, device_t *device);

int channel_open_modbus(channel_t *channel);

void channel_close_modbus(channel_t *channel);

//MODBUS数据采集计划
void sched_modbus_device_segment(channel_t *channel, data_catalog_e catalog, device_t *device, segment_e segment);

void sched_modbus_device(channel_t *channel, data_catalog_e catalog, device_t *device);

void sched_modbus_channel(channel_t *channel, data_catalog_e catalog);

void sched_modbus_catalogs(channel_t *channel, seqiot_t *seqiot);

void sched_modbus(channel_t *channel, seqiot_t *seqiot);

#endif //SEQIOT_MODBUS_ACQUIRE_H
